package team.se.tms.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import team.se.tms.dao.Dao;
import team.se.tms.dto.Page;
import team.se.tms.dto.ParameterMap;
import team.se.tms.dto.ParameterPage;
import team.se.tms.po.ImageInfo;
import team.se.tms.service.ImageInfoService;

import javax.annotation.Resource;
import java.util.List;

/**
 * 图片信息业务层，具体实现图片信息业务接口层定义的方法
 *
 * @author winkyle
 * @date 2018/11/6
 */
@Slf4j
@Service("ImageInfoServiceImpl")
public class ImageInfoServiceImpl extends BaseServiceImpl implements ImageInfoService {

    @Resource(name = "DaoImpl")
    private Dao dao;

    /**
     * 根据图片名字与图片是否展示获取图片信息
     *
     * @param imageName 图片名字
     * @param imageShow 图片是否可见
     * @param page 分页
     * @return 图片信息列表
     * @throws Exception 异常
     * @create on 2018/11/11 by winkyle
     */
    @Override
    public List<ImageInfo> listImageInfos(String imageName, boolean imageShow, Page page) throws Exception{
        boolean sort = true;
        if(page != null){
            sort = false;
        }
        List<ImageInfo> imageInfos = dao.selectList("ImageInfoMapper.selectImageInfosByImageNameAndImageShow", getParameterPage(page,"imageName",imageName,"imageShow",imageShow,"sort",sort));
        log.debug("{}图片共{}张",imageName,imageInfos.size());
        return imageInfos;
    }
}
